package logicGame.Cards;

import java.io.Serializable;
import logicGame.Board;
import logicGame.Player;

public class AndCard extends Card implements Serializable {

    boolean earth1, water1;
    int numAction2, op, times, nome;
    Action action2;

    public AndCard(int code, int earth, int water, String descrition, String resource, int numResource, int numAction, int numAction2, int earth1, int water1, int nome) {
        super(code, earth, water, descrition, resource, numResource, numAction, nome);
        this.numAction2 = numAction2;
        this.op = 0;
        this.times = 0;
        this.earth1 = earth1 == 1;
        this.water1 = water1 == 1;
        this.nome= nome;
        action = new Place();
        action2 = new Delete();
    }

    @Override
    public void DoAction(Player p, Board b, int place, int finish) {
        if (op == 1) {
            action.Do(p, b, place, finish);
            numAction -= 1;
            times++;

        } else if (op == 2) {
            action2.Do(p, b, place, finish);
            numAction2 -= 1;
            times++;
        }

    }

    @Override
    public boolean isEarth() {
        if (op == 1) {
            return earth;
        } else {
            return earth1;
        }
    }

    @Override
    public boolean isWater() {
        if (op == 1) {
            return water;
        } else {
            return water1;
        }
    }

    @Override
    public int getOp() {
        return op;
    }

    @Override
    public void setOp(int op) {
        this.op = op;
    }

    @Override
    public Action getAction() {
        if (op == 1) {
            return action;
        } else {
            return action2;
        }
    }

    @Override
    public int getNumAction() {
        if (op == 1) {
            return numAction;
        } else {
            return numAction2;
        }
    }

    @Override
    public int getTimes() {
        return times;
    }

}
